﻿using Volo.Abp.Account;
using Volo.Abp.AutoMapper;
using Volo.Abp.BlobStoring;
using Volo.Abp.BlobStoring.FileSystem;
using Volo.Abp.FeatureManagement;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement;
using Volo.Abp.TenantManagement;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.BackgroundWorkers;
using Volo.Abp;
using Wy.JiZhangSoft.Backgrounds;
using Wy.JiZhangSoft.Files;

namespace Wy.JiZhangSoft
{
    [DependsOn(
        typeof(JiZhangSoftDomainModule),
        typeof(AbpAccountApplicationModule),
        typeof(JiZhangSoftApplicationContractsModule),
        typeof(AbpIdentityApplicationModule),
        typeof(AbpPermissionManagementApplicationModule),
        typeof(AbpTenantManagementApplicationModule),
        typeof(AbpFeatureManagementApplicationModule),
        typeof(AbpBlobStoringFileSystemModule),
        typeof(AbpBackgroundWorkersModule)
        )]
    public class JiZhangSoftApplicationModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            var configuration=  context.Services.GetConfiguration();
            Configure<FileOptions>(configuration.GetSection("FileSettings"));
            Configure<AbpBlobStoringOptions>(options =>
            {
                options.Containers.ConfigureDefault(container =>
                {
                    container.UseFileSystem(fileSystem =>
                    {
                        fileSystem.BasePath = configuration["FileSettings:UploadPath"];
                    });
                });
            });

            Configure<AbpAutoMapperOptions>(options =>
            {
                options.AddMaps<JiZhangSoftApplicationModule>();
            });
        }

        public override void OnApplicationInitialization(ApplicationInitializationContext context)
        {
            context.AddBackgroundWorker<ZhiChuStatisticWork>();
        }
    }
}
